package com.dfbz.demo;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo02_foreach {


    public static void main(String[] args) {

        Collection listCities=new ArrayList();
        listCities.add("广州");
        listCities.add("深圳");
        listCities.add("佛山");
        listCities.add("中山");


        // 使用foreach迭代的时候不能对集合进行增删
        for (Object listCity : listCities) {
            System.out.println(listCities);

//            listCities.add("韶关");
//            listCities.remove(listCity);
        }


    }
    public static void test(String[] args) {

        String[] arrCities= {"阳江","江门","珠海","佛山"};

        for (String arrCity : arrCities) {
            System.out.println(arrCity);
        }
        System.out.println("---------------");

        Collection listCities=new ArrayList();
        listCities.add("雷州");
        listCities.add("电白");

        for (Object city : listCities) {
            System.out.println(city);
        }

    }
}
